<template>
    <div>
        <h1>管理员登录</h1>
        <table class="table table-bordered" style="background-color: burlywood;">
            <tbody>
                <tr>
                    <td>用户名</td>
                    <td><input type="text" v-model="info.account"></td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td><input type="password" v-model="info.pwd"></td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="button" value="登录" @click="login"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref} from 'vue'
import axios from 'axios';
import { onMounted } from 'vue';

let info:any=ref( {
  "id": 0,
  "account": "",
  "pwd": ""
})

const login=()=>{
    if(info.value.account==""){
        alert("用户名不能为空")
        return;
    }
    if(info.value.pwd==""){
        alert("密码不能为空")
        return;
    }
      axios({
        url:'https://localhost:7118/api/Room/Login',
        method:'post',
        data:info.value
    })
    .then((res)=>{
        console.log(res)
        if(res.data==-1){
            alert("用户名错误")
            return;
        }
        alert("登录成功")
        location.href='/roomshow'
    })
    .catch((err)=>{
        console.log(err);
    })
}

</script>

<style scoped>

</style>